/*
 * @Author: hwoeMa
 * @Date: 2025-06-04 10:47:50
 * @LastEditors: hwoeMa
 * @LastEditTime: 2025-06-10 15:47:49
 * @Description: 
 */
import { _decorator, Component, EffectAsset, Graphics, Material, Node, Sprite } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Draw')
export class Draw extends Component {

    @property({ type: Sprite })
    SHADERsP: Sprite;

    @property(EffectAsset)
    myEfffff:EffectAsset = null;

    start() {

        // let myEff = new Material();
        // myEff.initialize({ effectAsset: this.myEfffff, defines: { USE_TEXTURE :true}})
        // this.SHADERsP.customMaterial = myEff;
        // return;

        const g = this.getComponent(Graphics);
        g.fillRect(0, 500, 200, 200);

        const sprite = this.SHADERsP;
        const mat = sprite.customMaterial;
        let value = 0;
        mat.setProperty('dissolveThreshold', value);
        let isToBig = false;
        this.schedule(() => {
            if (isToBig) {
                value -= 0.005;
            } else {
                value += 0.005;
            }
            mat.setProperty('dissolveThreshold', value);
            if (value > 1) {
                isToBig = true;
            } else if (value <= 0) {
                isToBig = false;
            }

        }, 0.01)
    }

    update(deltaTime: number) {

    }
}


